<template>
	<view class="content">
		<view class="subject">
			<view class="bg">
				<view class="top">
					<text class="title">定金历史记录</text>
					<view class="form">
						<view class="inp">
							<view class="box">
								<u-input v-model="buy" placeholder='购买人' />
							</view>
							<view class="box">
								<u-input v-model="referer" placeholder='邀请人' />
							</view>
						</view>
						<view class="inp">
							<view class="box" @click="show = true">
								<u-input v-model="begin" placeholder='购买开始日期' />
							</view>
							<view class="box" @click="show1 = true">
								<u-input v-model="end" placeholder='购买结束日期' />
							</view>
						</view>
						<view class="inp">
							<view class="box">
								<u-input v-model="status" placeholder='全部状态' />
							</view>
							<view class="boxbtn" @click="submit">
								搜 索
							</view>
						</view>
					</view>

					<view v-if="list.length > 0">
						<view class="list">
							<view class="item" v-for="(item,index) in list" :key="index">
								<view class="left">
									<text class="desc">{{item.title}}</text>
									<view class="text">
										<image src="../../static/icon/3_16.png" mode=""></image>
										<text>{{item.price}}元</text>
									</view>
									<view class="text">
										<image src="../../static/icon/3_20.png" mode=""></image>
										<text>{{item.create_at}}</text>
									</view>
									<view class="text">
										<image src="../../static/icon/3_24.png" mode=""></image>
										<text>购买人：{{item.name}}</text>
									</view>
								</view>
								<view class="right">
									<image src="../../static/icon/3_11.png" mode="" v-if="item.status == 1"></image>
									<image src="../../static/icon/3_14.png" mode="" v-else></image>
									<text>邀请人:{{item.referer}}</text>
								</view>
							</view>
						</view>
						<page-pagination :total="page.total"
							layout="total,first,prev,page,next,last,limit,jumper"></page-pagination>
					</view>
					<u-empty mode="history" icon="http://cdn.uviewui.com/uview/empty/history.png" v-else>
					</u-empty>
					<view style="height: 100rpx;">
					</view>

				</view>
			</view>
		</view>
		<u-datetime-picker :show="show" v-model="value" mode="date" @confirm="confirm"></u-datetime-picker>
		<u-datetime-picker :show="show1" v-model="value1" mode="date" @confirm="confirm1"></u-datetime-picker>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				show1: false,
				list: [],
				value: '',
				value1: '',
				page: {
					total: 10000,
					pageSize: 50,
					currentPage: 2
				},
				buy: '',
				referer: '',
				begin: '',
				end: '',
				status: '',
			};
		},
		onShow() {

		},
		onLoad() {

		},
		methods: {
			confirm(e) {
				let ret = this.UnixToDate(e.value);
				this.begin = ret
				this.show = false
			},
			confirm1(e) {
				let ret = this.UnixToDate(e.value);
				this.end = ret
				this.show1 = false
			},
			UnixToDate(unixTime) {
				let _date = new Date(parseInt(unixTime));
				let y = _date.getFullYear();
				let m = _date.getMonth() + 1;
				m = m < 10 ? "0" + m : m;
				let d = _date.getDate();
				d = d < 10 ? "0" + d : d;
				let h = _date.getHours();
				h = h < 10 ? "0" + h : h;
				let minute = _date.getMinutes();
				let second = _date.getSeconds();
				minute = minute < 10 ? "0" + minute : minute;
				second = second < 10 ? "0" + second : second;
				let dates =
					y + "-" + m + "-" + d
				return dates;
			},


			submit() {
				let {
					buy,
					referer,
					begin,
					end,
					status
				} = this
				let params = {
					buy,
					referer,
					begin,
					end,
					status,
				}
				uni.request({
					url: `https://e.s8jd.com/prod-api/api/mock/request?url=/api/zsxq/getOrders`, // 服务器地址
					method: 'GET', // 请求方式
					data:params,
					success: (res) => {
						console.log(res)
						this.list = res.data
					},
					fail: (err) => {
						console.log(err)
					}
				})
			}
		},
	};
</script>

<style lang="scss" scoped>
	.content {
		.subject {
			position: relative;

			.bg {
				width: 750rpx;
				height: 445rpx;
				background: url("~@/static/bg1.png") no-repeat;
				background-size: 100% 100%;

				.top {
					width: 681rpx;
					height: 1256rpx;
					margin: 0 auto;
					position: relative;
					top: 70rpx;

					.title {
						width: 150rpx;
						height: 24rpx;
						font-family: Microsoft YaHei;
						font-weight: 400;
						font-size: 25rpx;
						color: #6C6C6C;
					}

					.form {
						.inp {
							display: flex;
							justify-content: space-between;
							margin-top: 20rpx;

							.box {
								width: 320rpx;
							}

							.boxbtn {
								width: 320rpx;
								line-height: 80rpx;
								background: linear-gradient(0deg, #16B998 0%, #31E6C1 100%);
								border-radius: 10rpx;
								opacity: 0.8;
								font-family: Microsoft YaHei;
								font-weight: 400;
								font-size: 25rpx;
								color: #FFFFFF;
								text-align: center;
							}

							.u-input {
								width: 320rpx;
								height: 80rpx;
								background: #FFFFFF;
							}
						}
					}

					.list {
						padding-bottom: 40rpx;

						.item {
							width: 681rpx;
							background: #FFFFFF;
							box-shadow: 0rpx 0rpx 17rpx 0rpx rgba(38, 175, 164, 0.05);
							border-radius: 21rpx;
							padding: 42rpx 56rpx 42rpx 50rpx;
							display: flex;
							align-items: center;
							justify-content: space-between;
							margin-top: 35rpx;

							.left {
								.desc {
									font-family: Microsoft YaHei;
									font-weight: bold;
									font-size: 31rpx;
									color: #171717;
								}

								.text {
									display: flex;
									align-items: center;
									padding-top: 16rpx;

									text {
										font-family: Microsoft YaHei;
										font-weight: 400;
										font-size: 25rpx;
										color: #6C6C6C;
										padding-left: 10rpx;
									}

									image {
										width: 26rpx;
										height: 26rpx;
									}
								}
							}

							.right {
								image {
									width: 126rpx;
									height: 109rpx;
									display: block;
								}

								text {
									font-family: Microsoft YaHei;
									font-weight: 400;
									font-size: 25rpx;
									color: #6C6C6C;
									display: block;
									padding-top: 40rpx;
								}
							}
						}
					}
				}
			}


		}

	}
</style>